home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_mac.hqx / SRGP port to 5.0 (compressed) / SRGP_SPHIGS Root / MacSPHIGS / sph_post.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-13  |  3.2 KB  |  114 lines

  1. #include "HEADERS.h"
  2. #include "sphigslocal.h"
  3.  
  4. #define PROPER_VIEW  SPH_viewTable[viewIndex]
  5.  
  6. #include "sph_post.proto.h"
  7.  
  8.  
  9. /** SPH_postRoot
  10. I make no attempt to verify that this very structure hasn't already
  11. been posted to this very view.
  12.  
  13. Strange thing: let's say that I post while regeneration is suppressed.
  14. And immediately obtain a pointer measure.  It would be possible for an
  15. object in the newly posted network to be "picked" via the correlation
  16. even though it has never appeared on the screen!
  17. **/
  18. void
  19. SPH_postRoot (int structID, int viewIndex)
  20. {
  21.    root_header *baby_network;
  22.  
  23.    SPH_check_system_state;
  24.    SPH_check_no_open_structure;
  25.    SPH_check_structure_id;
  26.    SPH_check_view_index;
  27.  
  28.    ALLOC_RECORDS (baby_network, root_header, 1);
  29.    baby_network->root_structID = structID;
  30.  
  31.    SPH__structureTable[structID].refcount++;
  32.  
  33.    /* ADD TO VIEW DATABASE: to have highest overlap in its own view's list */
  34.    baby_network->nextHigherOverlapRoot = NULL;
  35.    baby_network->nextLowerOverlapRoot = PROPER_VIEW.highestOverlapNetwork;
  36.    if (PROPER_VIEW.lowestOverlapNetwork == NULL)
  37.       PROPER_VIEW.lowestOverlapNetwork = baby_network;
  38.    else
  39.       PROPER_VIEW.highestOverlapNetwork->nextHigherOverlapRoot = baby_network;
  40.    PROPER_VIEW.highestOverlapNetwork = baby_network;
  41.  
  42.    VIEWOPT__afterNewPosting (&PROPER_VIEW, structID);
  43.    SPH__refresh_post (viewIndex);
  44. }
  45.  
  46.  
  47.  
  48. /*!*/
  49. void
  50. SPH_unpostRoot (int structID, int viewIndex)
  51. {
  52.    root_header *network_to_die;
  53.  
  54.  
  55.    SPH_check_system_state;
  56.    SPH_check_no_open_structure;
  57.    SPH_check_structure_id;
  58.    SPH_check_view_index;
  59.  
  60.    /* LOOK FOR THE ROOT HEADER BY SCANNING VIEW'S NETWORK LIST */
  61.    network_to_die = PROPER_VIEW.highestOverlapNetwork;
  62.    while (network_to_die->root_structID != structID) {
  63.       network_to_die = network_to_die->nextLowerOverlapRoot;
  64.       if (network_to_die == NULL)
  65.      SPH__error (ERR_UNPOST_NONEXTANT_ROOT);
  66.    }
  67.  
  68.    /* DELETE W/ HIGHER OVERLAPPERS */
  69.    if (network_to_die->nextHigherOverlapRoot == NULL)
  70.       PROPER_VIEW.highestOverlapNetwork = network_to_die->nextLowerOverlapRoot;
  71.    else
  72.       network_to_die->nextHigherOverlapRoot->nextLowerOverlapRoot =
  73.      network_to_die->nextLowerOverlapRoot;
  74.    /* DELETE W/ LOWER OVERLAPPERS */
  75.    if (network_to_die->nextLowerOverlapRoot == NULL)
  76.       PROPER_VIEW.lowestOverlapNetwork = network_to_die->nextHigherOverlapRoot;
  77.    else
  78.       network_to_die->nextLowerOverlapRoot->nextHigherOverlapRoot =
  79.      network_to_die->nextHigherOverlapRoot;
  80.  
  81.    SPH__structureTable[structID].refcount--;
  82.  
  83.    VIEWOPT__afterUnposting (&PROPER_VIEW, structID);
  84.    SPH__refresh_unpost (viewIndex);
  85.    
  86.    free (network_to_die);
  87. }
  88.  
  89.  
  90.  
  91. /*!*/
  92. void
  93. SPH_unpostAllRoots (int viewIndex)
  94. {
  95.    root_header *network_to_die, *next_network_to_die;
  96.  
  97.    SPH_check_system_state;
  98.    SPH_check_no_open_structure;
  99.    SPH_check_view_index;
  100.  
  101.    network_to_die = PROPER_VIEW.highestOverlapNetwork;
  102.    while (network_to_die != NULL) {
  103.       next_network_to_die = network_to_die->nextLowerOverlapRoot;
  104.       SPH__structureTable[network_to_die->root_structID].refcount--;
  105.       free (network_to_die);
  106.       network_to_die = next_network_to_die;
  107.    }
  108.    
  109.    PROPER_VIEW.highestOverlapNetwork = PROPER_VIEW.lowestOverlapNetwork = NULL;
  110.    
  111.    ClearBitstring (&(PROPER_VIEW.descendent_list));
  112.    SPH__refresh_unpost (viewIndex);
  113. }
  114.